﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PrinteMaster
{
    public partial class 特殊接口_删除指定员工账号 : Form
    {
        public 特殊接口_删除指定员工账号()
        {
            InitializeComponent();
        }
        DataSet req = null;
        private void 特殊接口_删除指定员工账号_Load(object sender, EventArgs e)
        {
            DataBase.Error er = DataBase.getInstance().selectTable("员工账号", "", out req);
            dgv.DataSource = req.Tables[0].DefaultView;
        }

        private void dgv_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (MessageBox.Show("是否删除指定会员?", "", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        var str = this.req.Tables[0].Rows[dgv.CurrentRow.Index][0].ToString();
                        MySqlHelper.GetDataSet(MySqlHelper.Conn, CommandType.Text, "delete from 员工账号 where 编号 = " + str);
                        MessageBox.Show("删除成功!");
                        DataBase.Error er = DataBase.getInstance().selectTable("员工账号", "", out req);
                        dgv.DataSource = req.Tables[0].DefaultView;
                    }
                    catch (Exception ex) { Console.Write(ex.Message); MessageBox.Show("数据库错误，错误原因=>" + ex.Message); }
        
                }
            }
        }
    }
}
